package com.haoxuewa.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.haoxuewa.dao.EssayTempDao;
import com.haoxuewa.entity.EssayTemp;
import com.haoxuewa.service.EssayTempService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class EssayTempServiceImpl extends ServiceImpl<EssayTempDao, EssayTemp> implements EssayTempService {

    private final EssayTempDao essayTempDao;

    @Autowired
    public EssayTempServiceImpl(EssayTempDao essayTempDao) {
        this.essayTempDao = essayTempDao;
    }


    @Override
    public Boolean EssayAuditUnPass(int essayId) {
        return essayTempDao.deleteById(essayId) == 1;
    }

    @Override
    public Page<EssayTemp> getAuditEssayList(int pageNum, int pageSize) {
        return essayTempDao.selectMapsPage(new Page(pageNum, pageSize),
                new QueryWrapper<EssayTemp>().select("id", "title"));
    }

    @Override
    public List<Map<String, Object>> getAuditEssayContent(int id) {
        return essayTempDao.selectMaps(new QueryWrapper<EssayTemp>().select("title", "text"));
    }

}
